import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:vape_xe/routes/app_pages.dart';
import 'package:vape_xe/services/services.dart';
import 'package:vape_xe/utils/utils.dart';
import 'package:vape_xe/widgets/widgets.dart';

import 'logic.dart';

class AccountInfoDetailView extends GetView<AccountInfoDetailController> {
  const AccountInfoDetailView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
          icon: const Icon(Icons.arrow_back_ios_new_rounded),
          onPressed: () => {Navigator.of(context).pop('刷新')},
        ),
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          28.hGap,
          Padding(
            padding: EdgeInsets.only(left: 28.w),
            child: Obx(
              () => Text(
                controller.isPhone ? 'Current phone number'.tr : 'Current email'.tr,
                style: TextStyle(fontSize: 28.sp, fontWeight: FontWeight.bold),
              ),
            ),
          ),
          32.hGap,
          InnerContainerWidget(
            child: Obx(() => Stack(
                  children: [
                    Align(
                      alignment: Alignment.center,
                      child: Text(
                        (controller.isPhone
                                ? '+${UserStore.to.profile.mobileType} ${UserStore.to.profile.mobile}'
                                : '${UserStore.to.profile.email}')
                            .split('')
                            .map((char) {
                          return controller.isObscured ? '*' : char;
                        }).join(''),
                        style: TextStyle(fontSize: 16.sp, fontFamily: 'Montserrat', fontWeight: FontWeight.bold),
                      ),
                    ),
                    Align(
                      alignment: Alignment.centerRight,
                      child: IconButton(
                          icon: Icon(
                            controller.isObscured ? Icons.visibility_off : Icons.visibility,
                            color: Colors.white54,
                          ),
                          onPressed: () {
                            controller.isObscured = !controller.isObscured;
                          }),
                    ),
                  ],
                )),
          ),
          36.hGap,
          GestureDetector(
            onTap: () => Get.offAndToNamed(Routes.ACCOUNTINFOCHANGE, arguments: {'type': controller.isPhone ? 0 : 1}),
            child: Container(
              height: 52.h,
              margin: EdgeInsets.symmetric(horizontal: 32.w),
              decoration: BoxDecoration(
                gradient: const LinearGradient(colors: [Color(0xff6EDEF7), Color(0xff3351EF)]),
                borderRadius: 100.radius,
              ),
              child: Center(
                child: Obx(
                  () => Text(
                    controller.isPhone ? 'Change phone number'.tr : 'Change email'.tr,
                    style: const TextStyle(fontFamily: 'Montserrat', fontWeight: FontWeight.bold),
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
